import { TItemSuit } from "../../../../Message/Db/Tables/TItemSuit";
import { GameDefConfig } from "../GameDefConfig";
import { Language } from "../../../../extend/language/Language";
import { EJewel } from "../../../../Message/Public/EJewel";
import { CareerUtil } from "../../view/common/util/CareerUtil";
import { SkillConfig } from "../SkillConfig";
type int = number;
//class SuitInfo
    
    export  class SuitInfo
    {
        constructor(arg1: TItemSuit, arg2: int=-1, arg3: Boolean=false)
        {
            
            this.partList = [];
            this.partIdList = [];
            this.addAttrArray = [];
            this.skillArray = [];
            this._career = arg2;
            this._isSpiritEquip = arg3;
            this.init(arg1);
            return;
        }

        public init(arg1: TItemSuit): void
        {
            var loc1=null;
            var loc2=0;
            var loc3=null;
            var loc4=null;
            if (arg1) 
            {
                this._itemSuit = arg1;
                this.code = arg1.code;
                this.name = arg1.name;
                this.num = arg1.num;
                loc1 = arg1.partList.split(",");
                loc2 = 0;
                while (loc2 < loc1.length) 
                {
                    if (this._isSpiritEquip) 
                    {
                        loc4 = GameDefConfig.instance.getESpiritEquipDef(int(loc1[loc2]));
                    }
                    else 
                    {
                        loc4 = GameDefConfig.instance.getEEquipDef(int(loc1[loc2]));
                    }
                    if (loc4) 
                    {
                        this.partList.push(loc4.name);
                        this.partIdList.push(loc4.id);
                    }
                    ++loc2;
                }
                loc3 = Language.getString(71429);
                this.attrValue1 = this.parseAttr(arg1.attr1, loc3);
                this.attrValue2 = this.parseAttr(arg1.attr2, loc3);
                this.attrValue3 = this.parseAttr(arg1.attr3, loc3);
                this.attrValue4 = this.parseAttr(arg1.attr4, loc3);
                this.attrValue5 = this.parseAttr(arg1.attr5, loc3);
                this.attrValue6 = this.parseAttr(arg1.attr6, loc3);
                this.attrValue7 = this.parseAttr(arg1.attr7, loc3);
                this.attrValue8 = this.parseAttr(arg1.attr8, loc3);
                this.addAttrArray.push(this.attrValue1);
                this.addAttrArray.push(this.attrValue2);
                this.addAttrArray.push(this.attrValue3);
                this.addAttrArray.push(this.attrValue4);
                this.addAttrArray.push(this.attrValue5);
                this.addAttrArray.push(this.attrValue6);
                this.addAttrArray.push(this.attrValue7);
                this.addAttrArray.push(this.attrValue8);
            }
            return;
        }

        public parseAttr(arg1: string, arg2: string): string
        {
            var loc3=0;
            var loc4=0;
            var loc5=null;
            var loc6=0;
            var loc7=null;
            var loc8=null;
            var loc9=null;
            var loc10=null;
            var loc11=null;
            var loc12=null;
            var loc1="";
            var loc2=[];
            if (arg1 && arg1.length > 0) 
            {
                if (arg1.indexOf("#") == -1) 
                {
                    loc2.push(arg1);
                }
                else 
                {
                    loc2 = arg1.split("#");
                }
                loc4 = 0;
                while (loc4 < loc2.length) 
                {
                    loc5 = loc2[loc4];
                    loc6 = 0;
                    loc7 = "";
                    loc8 = "";
                    loc9 = "";
                    if (loc5.indexOf(",") != -1) 
                    {
                        if ((loc11 = loc5.split(",")).length == 2) 
                        {
                            if ((loc6 = int(loc11[0])) == EJewel._EJewelMagicAttack || loc6 == EJewel._EJewelMagicCrit) 
                            {
                                if (!(!(this._career == -1) && CareerUtil.isPhysicalCareer(this._career))) 
                                {
                                    loc7 = loc11[1];
                                    if (loc6 == 10000) 
                                    {
                                        this.isSkillAdd = true;
                                    }
                                    else if ((loc12 = GameDefConfig.instance.getEJewel(loc6)) && this._career == -1) 
                                    {
                                        loc8 = loc12.name + arg2;
                                    }
                                    else if (loc12) 
                                    {
                                        loc8 = loc12.text1 + arg2;
                                    }
                                    if (loc6 == 10000) 
                                    {
                                        if (loc10 = SkillConfig.instance.getInfoByName(parseInt(loc7))) 
                                        {
                                            loc9 = loc10.skillDescription;
                                        }
                                        this.skillArray.push(int(loc7));
                                    }
                                    else if (loc7.length <= 3) 
                                    {
                                        loc9 = loc7 + "%";
                                    }
                                    else 
                                    {
                                        loc9 = loc7.substring(0, loc7.length - 3);
                                    }
                                    loc1 = loc1 + (loc8 + "  " + loc9 + "  ");
                                    ++loc3;
                                    if (loc3 == 3) 
                                    {
                                        loc1 = loc1 + "\n";
                                        loc3 = 0;
                                    }
                                }
                            }
                            else if (loc6 == EJewel._EJewelPhysicalAttack || loc6 == EJewel._EJewelPhysicalCrit) 
                            {
                                if (!(!(this._career == -1) && CareerUtil.isMagicCareer(this._career))) 
                                {
                                    loc7 = loc11[1];
                                    if (loc6 == 10000) 
                                    {
                                        this.isSkillAdd = true;
                                    }
                                    else if ((loc12 = GameDefConfig.instance.getEJewel(loc6)) && this._career == -1) 
                                    {
                                        loc8 = loc12.name + arg2;
                                    }
                                    else if (loc12) 
                                    {
                                        loc8 = loc12.text1 + arg2;
                                    }
                                    if (loc6 == 10000) 
                                    {
                                        if (loc10 = SkillConfig.instance.getInfoByName(parseInt(loc7))) 
                                        {
                                            loc9 = loc10.skillDescription;
                                        }
                                        this.skillArray.push(int(loc7));
                                    }
                                    else if (loc7.length <= 3) 
                                    {
                                        loc9 = loc7 + "%";
                                    }
                                    else 
                                    {
                                        loc9 = loc7.substring(0, loc7.length - 3);
                                    }
                                    loc1 = loc1 + (loc8 + "  " + loc9 + "  ");
                                    ++loc3;
                                    if (loc3 == 3) 
                                    {
                                        loc1 = loc1 + "\n";
                                        loc3 = 0;
                                    }
                                }
                            }
                            else 
                            {
                                loc7 = loc11[1];
                                if (loc6 == 10000) 
                                {
                                    this.isSkillAdd = true;
                                }
                                else if ((loc12 = GameDefConfig.instance.getEJewel(loc6)) && this._career == -1) 
                                {
                                    loc8 = loc12.name + arg2;
                                }
                                else if (loc12) 
                                {
                                    loc8 = loc12.text1 + arg2;
                                }
                                if (loc6 == 10000) 
                                {
                                    if (loc10 = SkillConfig.instance.getInfoByName(parseInt(loc7))) 
                                    {
                                        loc9 = loc10.skillDescription;
                                    }
                                    this.skillArray.push(int(loc7));
                                }
                                else if (loc7.length <= 3) 
                                {
                                    loc9 = loc7 + "%";
                                }
                                else 
                                {
                                    loc9 = loc7.substring(0, loc7.length - 3);
                                }
                                loc1 = loc1 + (loc8 + "  " + loc9 + "  ");
                                ++loc3;
                                if (loc3 == 3) 
                                {
                                    loc1 = loc1 + "\n";
                                    loc3 = 0;
                                }
                            }
                        }
                    }
                    ++loc4;
                }
            }
            return loc1;
        }

        public get itemSuit(): TItemSuit
        {
            return this._itemSuit;
        }

        public /* var */code: int;

        public /* var */name: string;

        public /* var */num: int;

        public /* var */attrValue1: string;

        public /* var */attrValue2: string;

        public /* var */attrValue3: string;

        public /* var */attrValue4: string;

        public /* var */attrValue5: string;

        public /* var */attrValue6: string;

        public /* var */attrValue7: string;

        public /* var */attrValue8: string;

        public /* var */partList: Array<any>;

        public /* var */partIdList: Array<any>;

        public /* var */addAttrArray: Array<any>;

        public /* var */skillName: string;

        public /* var */isSkillAdd: Boolean=false;

        public /* var */skillArray: Array<any>;

        /* internal */ /* var */_itemSuit: TItemSuit;

        /* internal */ /* var */_career: int;

        /* internal */ /* var */_isSpiritEquip: Boolean;
    }
